package HojaTrabajo3;

/**
 * bubblesort.java
 * @author Douglas Dávila
 * ordenamiento tipo bubble
 */
public class BubbleSort {
    
   /**
    * tomado en http://www.leepoint.net/notes-java/data/arrays/32arraybubblesort.html
    * @param list arreglo a ordenar
    */ 
   public void bubbleSort(Comparable[] list) {
	/**Nos almacena el largo de la lista*/
    int n = list.length;
    for (int pass=1; pass < n; pass++) {  // count how many times
        // This next loop becomes shorter and shorter
        for (int i=0; i < n-pass; i++) {
            if ((Integer)list[i] > (Integer)list[i+1]) {
                // exchange elements
                int temp = (Integer)list[i];  list[i] = list[i+1];  list[i+1] = temp;
            }
        }
    }
}
    
}
